package frontend.pages.base;

import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.WebPage;

import shared.other.UserRolesDefinition;

import frontend.components.header.HeaderPanel;
import frontend.components.help.ContextualHelpPanel;

@AuthorizeInstantiation(value = {UserRolesDefinition.EMPLOYEE_ROLE_KEY, UserRolesDefinition.ADMIN_ROLE_KEY, UserRolesDefinition.FOREMAN_ROLE_KEY})
public abstract class BaseWebPage extends WebPage {

	public BaseWebPage(String helpPanelText) {
		initPage(helpPanelText);
	}

	private void initPage(String helpPanelText) {
		
		add(new HeaderPanel("header"));
		add(new ContextualHelpPanel("contextHelp", helpPanelText));
        add(createLeftSidePanel("hookMarkupComponent"));
	}

    /**
     * Override this method in order to add custom panels to the left side of the page
     * @param componentToBeAddedId - the id that must be assigned to the created component
     */
    protected WebMarkupContainer createLeftSidePanel(String componentToBeAddedId) {
        WebMarkupContainer hookMarkupComponent = new WebMarkupContainer(componentToBeAddedId);
        hookMarkupComponent.setOutputMarkupId(true);
        hookMarkupComponent.setVisible(false);
        return hookMarkupComponent;
    }

}
